#ifndef __APP_MYSQL__
#define __APP_MYSQL__

#include "mysql.h"
#include "CTSoBase.h"
#include "CTMsgBase.h"
#include "CTMySQL.h"
#include "CTCodeMySQL.h"
#include "commmsg.h"
#include "commerrno.h"

using namespace CTLib;

class CAppMysql : public CTSoAppInf
{
public:
	CAppMysql();
	virtual ~CAppMysql();

	virtual int Init(void *);
	virtual int Do(const CEnpNetHead& stHead, const char* pszReqBuf, int iReqLen,
		char* pszAnsBuf, int iAnsBufLen, int& iAnsLen);
	virtual int Exit();

private:
	CTMySQL m_stDb;
	int ConnectToDB();
	int DisconnectFromDB();

private:
	CTMsgHead m_stMsgHead;
	CReqSQL m_stReqSql;
	CTCodeMySQLResult m_stAnsSql;
	CTCodeStream m_stCodeStream;
	int m_iOpType;

	int InitReq(const char* pszReqBuf, int iReqLen);
	int DealReq();
	int SendAns(int iResult, char* pszAnsBuf, int iAnsBufLen, int& iAnsLen);
};



#endif
